home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_16_1987_Transactor_Publishing.d64
/
convert c-power
< prev
next >
Wrap
Text File
|
2023-02-26
|
4KB
|
170 lines
/* program to convert Super C */
/* files to/from SEQ files */
/* converting filetypes */
/* and control codes */
#define POWER
#ifdef POWER
#include "stdio.h"
#define CLR '\223'
#else
#include "h:stdio.h"
#endif
char inname[25];
char outname[25];
#ifdef POWER
FILE inchan;
FILE outchan;
#else
file inchan;
file outchan;
#endif
main()
{SHIFT-+}
int menu();
int choice ;
int status = 0;
char inbuff[255];
char outbuff[255];
while ( ( choice = menu() ) != '0' )
{SHIFT-+}
choice = ( choice == '1' ) ? 1 : 2 ;
putchar(CLR);
#ifdef POWER
getchar();
#endif
namefile("Source ", inname);
namefile("Destination ", outname);
modnames( choice );
#ifdef POWER
inchan = fopen(inname,"r");
outchan = fopen(outname,"w");
#else
inchan = open(8,2,inname);
outchan = open(8,3,outname);
#endif
status = 0;
while (!status) /* read a line and convert it */
{SHIFT-+}
fgets(inbuff, 254, inchan);
#ifdef POWER
status = feof(inchan);
#else
status = EOF;
#endif
convert(choice, inbuff, outbuff);
fputs(outbuff, outchan);
printf("\n%s", outbuff );
{SHIFT--}
close(inchan);
close(outchan);
{SHIFT--}
{SHIFT--}
modnames( choice ) /* modify filename for */
int choice;
{SHIFT-+} /* read/write usr/seq */
switch (choice)
{SHIFT-+}
case 1 :
strcat(inname, ",u,r");
strcat(outname, ",s,w");
break;
case 2 :
strcat(inname, ",s,r");
strcat(outname, ",u,w");
break;
{SHIFT--}
{SHIFT--}
namefile(filetype, name) /* input filename */
char *filetype;
char *name; /* pass pointer to filename */
{SHIFT-+}
printf("\n%sfile name: ",filetype);
gets(name,16);
if ( *( name + ( strlen(name) -1 ) ) == '\n' ) /* Super C gets() fix */
*( name + ( strlen(name) -1 ) ) = '\0' ;
{SHIFT--}
int menu()
{SHIFT-+}
int choice;
do
{SHIFT-+}
printf("%c\n",CLR);
printf(" 1. Super C to Sequential\n");
printf(" 2. Sequential to Super C\n\n");
printf(" 0. EXIT");
choice = getchar();
{SHIFT--}
while ( ( choice != '0' ) && ( choice != '1' ) && ( choice != '2' ) );
return choice;
{SHIFT--}
convert(choice, inbuff, outbuff)
int choice;
char inbuff[];
char outbuff[];
{SHIFT-+}
static int linenum = 0 ;
int inndex=0;
int outndex=0;
if ( linenum == 0 )
switch (choice)
{SHIFT-+}
case 1:
inndex +=3 ;
linenum = 1 ;
copybuff(inbuff, outbuff, inndex, outndex);
break;
case 2:
outbuff[0] = 133;
outbuff[1] = 129;
outbuff[2] = 5;
outndex +=3;
linenum = 1;
copybuff( inbuff, outbuff, inndex, outndex );
break;
{SHIFT--}
else
switch (choice)
{SHIFT-+}
case 1:
inndex++;
copybuff(inbuff, outbuff, inndex, outndex);
break;
case 2:
outbuff[0] = 5;
outndex++;
copybuff(inbuff, outbuff, inndex, outndex);
break;
{SHIFT--}
{SHIFT--}
copybuff( inbuff, outbuff, inndex, outndex )
char inbuff[];
char outbuff[];
int inndex;
int outndex;
{SHIFT-+}
do
{SHIFT-+}
outbuff[ outndex ] = inbuff[ inndex ];
inndex++;
outndex++;
{SHIFT--}
while( inndex <= strlen( inbuff ) );
{SHIFT--}